import axios from 'axios'
import { Message } from 'element-ui'

const http = axios.create({
  baseURL: process.env.VUE_APP_BASE_API
})

// 请求拦截
http.interceptors.request.use(config => {
  return config
}, err => {
  Promise.reject(err)
})

// 响应拦截
http.interceptors.response.use(response => {
  return response
}, err => {
  if (err.response) {
    Message({
      message: err.response.data.message,
      type: 'error'
    })
  }
  Promise.reject(err)
})


export default http